package com.dx.result;


import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Result<T> {
    public static final int SUCCESS=1;
    public static final int ERROR=0;
    private int code;
    private String msg;
    private T data;
    public static class Builder<T> {
        private int code;
        private  String msg;
        private  T data;
        public Builder<T> code(int code){
            this.code=code;
            return this;
        }
        public Builder<T> msg(String msg){
            this.msg=msg;
            return this;
        }
        public Builder<T> data(T data){
            this.data=data;
            return this;
        }
        public Result<T> build(){
            Result<T> result = new Result<>();
            result.setData(data);
            result.setCode(code);
            result.setMsg(msg);
            return result;
        }



    }






//    public static <T> Result<T> success(T data){
//        Result<T> result=new Result<T>();
//        result.code=1;
//        result.setData(data);
//        return result;
//    }
//    public static <T> Result<T> success(){
//        Result<T> result=new Result<T>();
//        result.setCode(1);
//        return result;
//    }
//    public static <T> Result<T> error(String msg){
//        Result<T> result=new Result<>();
//        result.setCode(0);
//        result.setMsg(msg);
//        return result;
//    }
}
